package com.sl.ms.carriage.handler;

import com.sl.ms.carriage.domain.dto.WaybillDTO;
import com.sl.ms.carriage.entity.CarriageEntity;

public abstract class AbstractCarriageChainHandler {
    private AbstractCarriageChainHandler nextHandler;

    public abstract CarriageEntity doHandler(WaybillDTO waybillDTO);

    protected CarriageEntity doNextHandler(WaybillDTO waybillDTO, CarriageEntity carriageEntity) {
        if (nextHandler == null || carriageEntity != null) {
            return carriageEntity;
        }
        return nextHandler.doHandler(waybillDTO);
    }
    public void setNextHandler(AbstractCarriageChainHandler nextHandler){
        this.nextHandler=nextHandler;
    }
}
